/**
 * Copyright (c) Software Institute of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.editparts;

import org.eclipse.gef.EditPart;

import edu.pku.sei.modeler.edit.parts.AbstractTreeEditPartFactory;
import edu.pku.sei.modeler.model.core.MetaClass;
import edu.pku.sei.modeler.model.core.MetaComment;
import edu.pku.sei.modeler.model.core.MetaElement;
import edu.pku.sei.modeler.model.core.MetaEnum;
import edu.pku.sei.modeler.model.core.MetaGeneralization;
import edu.pku.sei.modeler.model.core.MetaPackage;
import edu.pku.sei.modeler.model.core.MetaReference;
import edu.pku.sei.modeler.model.structure.MetaShapeElement;


/**
 * @author xy
 *
 */
public class MetaTreeEditPartFactory extends AbstractTreeEditPartFactory{

//    public EditPart createEditPart(EditPart context, Object model) {
//    	EditPart part = null;
//
//		if (model instanceof MetaDiagram)
//			part = new DiagramTreeEditPart((MetaDiagram)model);
//		else if (model instanceof MetaShapeElement)
//			part = createUmlEditPart((MetaShapeElement)model);
//		if(part != null)
//			part.setModel(model); 
//	    return part;
//    }
    
    public EditPart createEditPart(MetaShapeElement shape)
	{
		EditPart part = null;
		MetaElement content = shape.getModelElement();
		if(content instanceof MetaClass) {
			part = new MetaClassTreeEditPart(shape);
		} 
//		else if(content instanceof edu.pku.modeler.model.uml.interfaces.Interface) {
//			part = new UMLInterfaceTreeEditPart((AbstractModel)model);
//		} 
		else if(content instanceof MetaComment) {
			part = new MetaCommentTreeEditPart(shape);
		} 
		else if(content instanceof MetaPackage) {
			part = new MetaPackageTreeEditPart(shape);
		}
		else if(content instanceof MetaEnum) {
			part = new MetaEnumTreeEditPart(shape);
		}
//		else if(content instanceof TemplateNode) {
//			part = new TemplateNodeTreeEditPart(shape);
//		}
//		else if(content instanceof TemplatePort) {
//			part = new TemplatePortTreeEditPart(shape);
//		}
		else if(content instanceof MetaReference) {
			part = new MetaReferenceEditPart(shape);
		}
		else if(content instanceof MetaGeneralization) {
			part = new MetaGeneralizationEditPart(shape);
		}
		else {
			part = super.createEditPart(shape);
		}
		return part;
	}
}